<?php
global $base_url;
$image_path = $base_url . '/' . imagecache_create_path('organization_image', $node->field_org_image[0]['filename']);

$campaigns = db_query('SELECT * FROM {content_type_sale_campaign}, {node} 
    WHERE content_type_sale_campaign.field_campaign_org_nid = %d
    AND content_type_sale_campaign.nid = node.nid', $node->nid);

while ($c = db_fetch_object($campaigns)) {
    $from = explode("T", $c->field_duration_value);
    $from_date = $from[0];
    $to = explode("T", $c->field_duration_value2);
    $to_date = $to[0];
    $from_year = ((int) substr($from_date, 0, 4));
    $from_month = ((int) substr($from_date, 5, 2));
    $from_day = ((int) substr($from_date, 8, 2));
    $from_timestamp = mktime(0, 0, 0, $from_month, $from_day, $from_year);

    $to_year = ((int) substr($to_date, 0, 4));
    $to_month = ((int) substr($to_date, 5, 2));
    $to_day = ((int) substr($to_date, 8, 2));
    $to_timestamp = mktime(0, 0, 0, $to_month, $to_day, $to_year);
    if (time() >= $from_timestamp && time() <= $to_timestamp) {
        $campaign_title = $c->title;
        $start_time = $from_date;
        $end_time = $to_date;
        $cam_gole = $c->field_compaign_goal_value;
    }
    if ($start_time == NULL) {
        $begin_time = '';
    } else {
        $begin_time = date("M d Y", strtotime("$start_time"));
    }

    if ($end_time == NULL) {
        $finish_time = '';
    } else {
        $finish_time = date("M d Y", strtotime("$end_time"));
    }
}

$join_html = drupal_get_form('core101_user_customization_org_join_form');
?>
<section class="organization_info">
    <img src="<?php echo $image_path; ?>" alt="st martin school" />
    <h2><?php print $node->title; ?></h2>
<?php if ($campaigns->num_row != NULL) : ?>
        <h3><?php print $campaign_title . '  -  ' . $begin_time . ' - ' . $finish_time; ?></h3>
        <h3 class="red"><?php print 'Our Goal - $' . $cam_gole ?></h3>
<?php endif; ?>
    <p><?php print $node->content['body']['#value'] ?></p>
    <div id="joinOrgWarper">
    <?php print $join_html; ?>
    </div>
</section>
